package com.seari.controller;

import com.seari.annotation.AppCacheName;
import com.seari.pojo.MessageBean;
import com.seari.service.TicketingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @ClassName TicketingController
 * @Description 票务相关
 * @Author zhangYanKun
 * @Date 2021/5/12 20:12
 * @Version 1.0
 */
@RestController
@RequestMapping("ticket")
public class TicketingController {

    @Autowired
    private TicketingService service;


    /**
     * @apiGroup 票务
     * @api {ALL} /ticket/percentage 实时票卡比例
     * @apiDescription 入站方式百分比
     * @apiParamExample 请求示例
     * /ticket/percentage
     * @apiSuccessExample 成功响应
     * HTTP/1.1 200
     * {
     *      "code": "200",
     *      "type": null,
     *      "message": null,
     *      "data": {
     *         "二维码": "38%",
     *         "单程票": "5%",
     *         "手机交通卡": "19%",
     *         "普通交通卡": "36%",
     *         "其他": "2%"
     *      },
     *      "total": 0
     *}
     * @apiVersion 0.0.1
     */
    @RequestMapping("percentage")
    @AppCacheName("ticketPercent")
    public MessageBean getTicketing(HttpServletRequest request){
        MessageBean result = new MessageBean();
        Map<String, String> data = service.getTicketing();
        result.setData(data);
        result.setCode("200");
        return result;
    }
}
